<?php
include('../../inc/global.inc');
include("../islogin.php");
$url="price.php";
$thepage=$_GET['page']?$_GET['page']:1;
$maxpage=20;
?>
<?php
//删除信息
if($_GET['del_act']){
$urls=$_SERVER['HTTP_REFERER'];
@mysql_query("delete from p_price where id='".$_GET['del_id']."'");
echo "<script>location='".$urls."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">产品价格系统&nbsp;&nbsp;<a href="javascript:history.go(-1)">Back</a></td>
    </tr>
  </table>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <form method="get" action="" name="form1">
      <tr>
        <td height="25" bgcolor="#EEEEF9" style="padding:5px;line-height:25px;">
产品名称：<input name="search_name" type="text" size="30">&nbsp;&nbsp;&nbsp;&nbsp;产品型号：<input name="s_xinghao" type="text" size="20"><br>

          <input name="submit" type="submit" value="搜索">
        </td>
      </tr>
    </form>
  </table>
<?php 
if($_GET[search_name]){
$search_sql=" and (p_price.p_title like '%$_GET[search_name]%' || p_price.p_info like '%$_GET[search_name]%')";
}
?>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
	  <td width="5%" height="30" align="center" bgcolor="#8DA8CF">编号</td>
      <td width="42%" align="center" bgcolor="#8DA8CF">产品信息</td>
      <td width="17%" align="center" bgcolor="#8DA8CF">联系电话</td>
      <td width="13%" align="center" bgcolor="#8DA8CF">联系手机</td>
      <td width="13%" align="center" bgcolor="#8DA8CF">在线QQ</td>
      <td width="10%" align="center" bgcolor="#8DA8CF">管理</td>
    </tr>
<?php
$sql="select p_price.id,p_price.p_title,p_price.member_id,p_price.p_info,p_price.p_price,p_price.p_price2,p_price.add_time,member.m_user,member.m_type,member.m_cname,member.m_tel,member.m_phone,member.m_qq from p_price inner join  member on (p_price.member_id=member.id) where 1=1 ".$search_sql." order by p_price.id desc limit ".($thepage-1)*$maxpage.",$maxpage";

$rs=@mysql_query($sql);
$i=1;
while($row=mysql_fetch_array($rs)){
if($row[m_type]==6){
   $m_url="http://$row[m_user].sandib2b.cn/";
}else{
   $m_url="/cn/template/$row[m_user]/";
}
$color=($i%2)?"#FFFFFF":"#eeeeee";
?>
    <tr bgcolor=<?=$color?>>
      <td height="25" align="center"><?=$i?></td>
	  <td align="left" style="padding-left:5px;padding:2px;"><b><?=$row[p_title]?></b><br>
<font color="#999999"><?=mb_substr(strip_tags($row[p_info]),0,50,'utf-8')?></font><br>
<font color="#FF0000">市场价格：<?=$row[p_price]?>&nbsp;-&nbsp;代理价格：<?=$row[p_price2]?></font><br>
<A href="<?=$m_url?>" target=_blank><?=$row['m_cname']?></A></td>
	  <td align="center"><?=$row['m_tel']?></td>
	  <td align="center"><?=$row['m_phone']?></td>
	  <td align="center"><?=$row['m_qq']?></td>
      <td align="center"><a href="price_modify.php?xg_id=<?=$row['id']?>">查看</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<?=$url?>?del_act=ok&del_id=<?=$row['id']?>" onClick="return del()">删除</a></td>
    </tr>
<?php
$i++;}
//分页参数

$rs2=@mysql_query("select count(p_price.id) from p_price inner join  member on (p_price.member_id=member.id)  where 1=1 ".$search_sql);
$totalrecord=@mysql_result($rs2,0);
$totalpage=ceil($totalrecord/$maxpage);
@mysql_free_result($rs2);
?>
<tr><form method="get" action="<?=$url?>">
   <td height="25" colspan="6" align="center" bgcolor="#FFFFFF">
<?php if($thepage>1){?>
   <a href="<?=$url?>">第一页</a>&nbsp;<a href="<?=$url?>?page=<?=$thepage-1?>">上一页</a>&nbsp;
<?php }?>  
<?php if($thepage!=$totalpage&&$totalpage>0){?>
   <a href="<?=$url?>?page=<?=$thepage+1?>">下一页</a>&nbsp;<a href="<?=$url?>?page=<?=$totalpage?>">最后一页</a>&nbsp;
<?php }?>   
   【共<font color="red"><?=$totalrecord?></font>条记录】【每页<font color="red"><?=$maxpage?></font>条记录】【共<font color="red"><?=$totalpage?></font>页】<input type="text" name="page" size="3" onKeyUp="IsDigit(this);">&nbsp;<input type="submit" value="GO"></td></form>
</tr>
  </table>
</center>
</BODY>
</HTML>

<script language="javascript">
function IsDigit(obj) 
{ 
if(obj.value.replace(/[\d+]/ig,"").length>0) { 
  alert('enter an number'); 
  document.getElementById(obj).value =""; 
} 
} 
</script>